package com.niit.session17;

import java.util.TreeSet;

public class TreeSetDemo {
	public static void main(String[] args) {
//		TreeSet会对插入的元素进行排序，插入和删除效率较低
		TreeSet<Integer> treeSet = new TreeSet<Integer>();
		treeSet.add(51);
		treeSet.add(15);
		treeSet.add(23);
		treeSet.add(52);
		System.out.println(treeSet);
//		TreeSet也可以对自己定义的实体类型排序
		TreeSet<Student> students = new TreeSet<Student>();
		students.add(new Student("张三",18));
		students.add(new Student("李四",21));
		students.add(new Student("王五",20));
		System.out.println(students);
	}

}
